//
//  HBSettingCell.m
//  HuoBao
//
//  Created by chaiyanan on 15/12/4.
//  Copyright © 2015年 jinxin. All rights reserved.
//

#import "HBSettingCell.h"

@implementation HBSettingCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        self.backgroundColor = [LCCommon getColor:@"37383d"];
        [self createCustomView];
    }
    return self;
}

- (void)createCustomView
{
    
    self.titleLable = [[UILabel alloc]initWithFrame:CGRectMake(15, 0, SCREEN_WIDTH-2*15, Height_HBSettingCell)];
    self.titleLable.font = [UIFont systemFontOfSize:16.0f];
    self.titleLable.textColor = [LCCommon getColor:@"999999"];
    self.titleLable.textAlignment = NSTextAlignmentLeft;
    
    UIImage *image = [UIImage imageNamed:@"income_zhaiquan"];
    self.arrowImageView = [[UIImageView alloc]initWithImage:image];
    self.arrowImageView.frame = CGRectMake(SCREEN_WIDTH-15-image.size.width, (Height_HBSettingCell-image.size.height)/2, image.size.width, image.size.height);
    
    self.mySwitch = [[UISwitch alloc]initWithFrame:CGRectMake(SCREEN_WIDTH-15-55, 5, 55, Height_HBSettingCell-10)];
    self.mySwitch.tintColor = [LCCommon getColor:@"939393"];
    self.mySwitch.thumbTintColor = [LCCommon getColor:@"d7d7d7"];
    self.mySwitch.onTintColor = [UIColor colorWithRed:109/255.0 green:180/255.0 blue:64/255.0 alpha:1.0];
//    self.mySwitch.onImage = [UIImage imageNamed:@"switch_on"];
    self.mySwitch.backgroundColor = [LCCommon getColor:@"939393"];
//    self.mySwitch.offImage = [UIImage imageNamed:@"switch_off"];
    self.mySwitch.layer.cornerRadius = 14;
    self.mySwitch.clipsToBounds = YES;
    self.mySwitch.hidden = YES;
    [self.mySwitch addTarget:self action:@selector(switchValueChanged:) forControlEvents:UIControlEventValueChanged];

    [self.contentView addSubview:self.titleLable];
    [self.contentView addSubview:self.arrowImageView];
    [self.contentView addSubview:self.mySwitch];
}

- (void)switchValueChanged:(UISwitch *)mySwitch
{
    if (self.ActionSwitchChange)
    {
        self.ActionSwitchChange(mySwitch);
    }
}

@end
